<template>
  <div>
    <!-- 有id用id,没id用索引 -->
    <!-- 
      注意:
      1.无key  -----就地更新
      2.有key  
        2.1key为索引值时,还是就地更新
        2.2key为唯一的字符串或数字-----推荐
      -->
    <ul>
      <li v-for="item in arr" :key="item.id">{{ item.name }}</li>
    </ul>
    <button @click="btnClick">点击</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      arr: [
        { name: "小马哥", id: 1 },
        { name: "安琪拉", id: 2 },
        { name: "马可波罗", id: 3 },
      ],
    };
  },
  methods: {
    btnClick() {
      this.arr.splice(1, 0, { name: "新来的", id: 4 });
    },
  },
};
</script>

<style>
</style>